//
//  FindMusicViewController.m
//  网易云音乐碎片
//
//  Created by dllo on 15/11/10.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "FindMusicViewController.h"

@interface FindMusicViewController ()

@end

@implementation FindMusicViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIImage *leftImage = [UIImage imageNamed:@"cm2_top_icn_mic.png"];
    leftImage = [leftImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [leftButton addTarget:self action:@selector(leftButton:) forControlEvents:UIControlEventAllTouchEvents];
    leftButton.frame = CGRectMake(0, 0, 20, 20);
    [leftButton setImage:leftImage forState:UIControlStateNormal];
    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:leftButton] autorelease];
    
    
//    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithImage:leftImage style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtonAction:)] autorelease];
//
//    UIImage *rightImage = [UIImage imageNamed:@"cm2_top_icn_playing.png"];
//    rightImage = [rightImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:rightImage style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButtonAction:)];
    
    
}

//- (void)leftBarButtonAction:(UIBarButtonItem *)button{
////    cm2_top_icn_mic_prs.png
//    UIImage *leftImage = [UIImage imageNamed:@"cm2_top_icn_mic_prs.png"];
//    leftImage = [leftImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    [self.navigationItem.leftBarButtonItem setImage:leftImage];
//    
//}

//- (void)rightBarButtonAction:(UIBarButtonItem *)button{
//    
//}

- (void)leftButton:(UIButton *)button{
    if (button.selected == NO) {
        UIImage *rightImage = [UIImage imageNamed:@"cm2_top_icn_mic.png"];
        rightImage = [rightImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        [button setImage:rightImage forState:UIControlStateNormal];
    } else {
    UIImage *rightImage = [UIImage imageNamed:@"cm2_top_icn_mic_prs.png"];
    rightImage = [rightImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [button setImage:rightImage forState:UIControlStateNormal];
    }
    button.selected = !button.selected;
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
